package com.nbsaas.boot.front.common;

import com.nbsaas.boot.common.api.apis.ModularApi;
import com.nbsaas.boot.common.api.domain.request.ModularRequest;
import com.nbsaas.boot.common.api.domain.request.ModularSearch;
import com.nbsaas.boot.common.api.domain.response.ModularResponse;
import com.nbsaas.boot.common.api.domain.simple.ModularSimple;
import com.nbsaas.boot.rest.annotations.ViewOperator;
import com.nbsaas.boot.rest.response.ListResponse;
import com.nbsaas.boot.rest.response.PageResponse;
import com.nbsaas.boot.rest.response.ResponseObject;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 模块控制器
 */
@RestController
@RequestMapping("/front/modular")
public class ModularAction {


    @Resource
    private ModularApi modularApi;

    /**
     * 搜索数据
     *
     * @param request
     * @return
     */
    @PostMapping("/search")
    public PageResponse<ModularSimple> search(@RequestBody ModularSearch request) {
        return modularApi.search(request);
    }

    /**
     * 列表数据
     *
     * @param request
     * @return
     */
    @PostMapping("/list")
    public ListResponse<ModularSimple> list(@RequestBody ModularSearch request) {
        return modularApi.list(request);
    }


    /**
     * 查看数据
     *
     * @param request
     * @return
     */
    @PostMapping("/view")
    public ResponseObject<ModularResponse> view(@RequestBody @Validated(ViewOperator.class) ModularRequest request) {
        return modularApi.view(request);
    }
}